package com.dyc.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class MainActivity extends AppCompatActivity {
    public static final String BASE_URL = "https://api.douban.com/v2/movie/";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //111111122222
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        MovieService  movieService = retrofit.create(MovieService.class);
//调用方法得到一个Call
        Call<Data> call = movieService.getTop250(0,20);
        //进行网络请求
    //         call.enqueue(new Callback<Data>() {
    //            @Override
    //            public void onResponse(Call<Data> call, Response<Data> response) {
    //
    //            }
    //            @Override
    //            public void onFailure(Call<Data> call, Throwable t) {
    //                t.printStackTrace();
    //            }
    //        });
            call.enqueue(new Callback<Data>() {

                @Override
                public void onResponse(Call call, Response response) {

                }

                @Override
                public void onFailure(Call call, Throwable t) {

                }
            });


    }
}
